# Makefile for libdgnsc
# Copyright (C) 2009-2010 drangon <drangon.zhou@gmail.com>
# 2009-05
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


SRCS = $(wildcard *.c)

OBJS = $(foreach src, $(SRCS), $(basename $(src)).o)
DEPS = $(foreach src, $(SRCS), $(basename $(src)).zzdep)
TARGETS = $(foreach src, $(SRCS), $(basename $(src)).exe)

AR = ar
CC = gcc
CFLAGS += -g -Wall -pipe -I../ 
LDFLAGS += -L../ -ldgnsc

ifeq ($(strip $(OS)),Windows_NT)
LDFLAGS += -lwinmm -lws2_32
else
LDFLAGS += -lpthread -lrt
endif

.PHONY : all clean test

all : $(TARGETS)

# $(CXX) $(CFLAGS) -x c++-header libtestfc.h

clean :
	rm -f $(TARGETS) *.o *.zzdep

$(TARGETS) : ../libdgnsc.a

$(TARGETS) : %.exe : %.o
	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

test :
	echo "TODO : run all test"


.SUFFIXES : .c

.c.o :
	$(CC) $(CFLAGS) -MMD -MF $*.zzdep -c -o $@ $<

-include $(DEPS)

